package com.tianxin.workbao.workBao.fragment;


import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


/**
 * Created by hacker on 2017/6/17.
 */

public abstract class BaseFragment extends Fragment {
    public final String TAG = getClass().getName() + "------------->";
    public View mRootView;
    public SwipeRefreshLayout mSwipeRefreshLayout;
    public RecyclerView mRecyclerView;
    public GridLayoutManager mLayoutManager;
    public int spanCount = 1;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        initRootView(inflater, container, savedInstanceState);
        initEvents();
        initData(savedInstanceState == null);
        return mRootView;
    }

    /**
     * 初始化根布局
     *
     * @return View 视图
     */
    public abstract void initRootView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);


    /**
     * 加载数据
     *
     * @param isSavedNull
     */
    public abstract void initData(boolean isSavedNull);

    /**
     * 初始化监听事件等
     */
    public abstract void initEvents();

    /**
     * 搜索的方法
     * @param query
     */
    public abstract void search(String query);
}
